package com.twu.biblioteca;

import org.junit.Test;

import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.HashMap;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

/**
 * Created with IntelliJ IDEA.
 * User: Thoughtworker
 * Date: 8/22/13
 * Time: 10:41 AM
 * To change this template use File | Settings | File Templates.
 */
public class BookLibrary {

    public HashMap<String, Boolean> books = new HashMap<String, Boolean>();
    private PrintStream printStream;
    private Printer printer;

    public BookLibrary(PrintStream printStream) {
        this.printStream = printStream;
        printer = new Printer(printStream, this);
    }


    public void addBook(String bookName) {
        books.put(bookName, true);

    }

    public void reserveBook(String bookName) {
        if (books.containsKey(bookName) && books.get(bookName)) {
            books.put(bookName, false);
            printer.thankYouMessage();
        } else printer.sorryMessage();
    }

    public void printBooks() {
        printStream.println(books.keySet().toString());
    }


}
